package eu.dominicum.ft.pd;

/**
 * Common ancestor class for all persistent domain objects.
 *
 * @author Harry Klerks
 * @since 2013M1
 */
public class PersistentDomainObject {

    /**
     * A generate obect ID.
     */
    private Long id;
    /**
     * A version number to support optimistic locking in JPA based repository implementations.
     */
    private Integer version;

    /**
     * .
     *
     * @return Long
     */
    public final Long getId() {
        return id;
    }

    /**
     * .
     *
     * @return Integer
     */
    public final Integer getVersion() {
        return version;
    }

    @Override
    public final int hashCode() {
        return super.hashCode();
    }

    @Override
    public final boolean equals(final Object obj) {
        PersistentDomainObject other;
        if (obj instanceof PersistentDomainObject) {
            other = (PersistentDomainObject) obj;
            if (this.id == null || other.id == null) {
                return false;
            }
            return this.id.equals(other.id);
        } else {
            return false;
        }
    }
}
